package com.ruoyi.project.wxapi.model.service.impl;

import com.ruoyi.project.wxapi.model.bean.Nurse;
import com.ruoyi.project.wxapi.model.mapper.NurseMapper;
import com.ruoyi.project.wxapi.model.service.INurseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.text.Convert;

import java.util.Date;
import java.util.List;

/**
 * 医生、护士、照护师Service业务层处理
 * 
 * @author finley
 * @date 2021-04-14
 */
@Service
public class NurseServiceImpl implements INurseService
{
    @Autowired
    private NurseMapper nurseMapper;

    /**
     * 查询医生、护士、照护师
     * 
     * @param id 医生、护士、照护师ID
     * @return 医生、护士、照护师
     */
    @Override
    public Nurse selectNurseById(Integer id)
    {
        return nurseMapper.selectNurseById(id);
    }

    /**
     * 查询医生、护士、照护师列表
     * 
     * @param nurse 医生、护士、照护师
     * @return 医生、护士、照护师
     */
    @Override
    public List<Nurse> selectNurseList(Nurse nurse)
    {
        return nurseMapper.selectNurseList(nurse);
    }

    /**
     * 新增医生、护士、照护师
     * 
     * @param nurse 医生、护士、照护师
     * @return 结果
     */
    @Override
    public int insertNurse(Nurse nurse)
    {
        return nurseMapper.insertNurse(nurse);
    }

    /**
     * 修改医生、护士、照护师
     * 
     * @param nurse 医生、护士、照护师
     * @return 结果
     */
    @Override
    public int updateNurse(Nurse nurse)
    {
        return nurseMapper.updateNurse(nurse);
    }

    /**
     * 删除医生、护士、照护师对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteNurseByIds(String ids)
    {
        return nurseMapper.deleteNurseByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除医生、护士、照护师信息
     * 
     * @param id 医生、护士、照护师ID
     * @return 结果
     */
    @Override
    public int deleteNurseById(Integer id)
    {
        return nurseMapper.deleteNurseById(id);
    }

    /**
     * 通过openid查询用户信息
     *
     * @param openId
     * @return
     */
    @Override
    public Nurse selectNurseByOpenid(String openId) {
        return nurseMapper.selectNurseByOpenid(openId);
    }

    /**
     * 申请审核
     *
     * @param userId
     */
    @Override
    public void applyCheck(Integer userId) {
        Nurse nurse = new Nurse();
        nurse.setId(userId);
        nurse.setSubmitDatetime(new Date());
        nurseMapper.updateNurse(nurse);
    }
}
